// +----------------------------------------------------------------------
// | BossHongshi [鸿时互娱管理系统]
// +----------------------------------------------------------------------
// | Copyright (c) 2018 http://www.hongshihuyu.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: wgh
// +----------------------------------------------------------------------
const fly=require("flyio")
var http=require('http');
module.exports = class extends think.Service {
  /**
     * init
     * @return {}         []
     */
  constructor(ctx) {
    super(ctx);
    this.http = ctx;
  }
  
  
  //查询俱乐部
  async getclubs() {
	//发送Get请求
	  const url='http://47.97.119.70:17100/club?uid=28&area=niuniuBackend&cmd=queryClub&sign=password';
	  /**
	  http.get(url,function(req,res){
	  	var html='';
	  	req.on('data',function(data){
	  		console.log('data--------------:'+data);
	  	});
	  	req.on('end',function(){
	  		console.info(html);
	  	});
	  });
	  */
	  let ret;
	  fly.config.timeout=10000;
	  // Set base url
	  fly.config.parseJson=true;
	  //let flyget  = think.promisify(fly.get);
	  //let response = await  flyget(url);
	  
//	  const makeRequest = async () => {
//		  const data = await fly.get(url);
//		  console.log('response data--------------3333----:'+JSON.stringify(data));
//		    
//		  if (data) {
//			  return data
//		  } 
//		}
	  
	  fly.get(url)
	  .then(function (response) {
		console.log('response data--------------3333----:'+JSON.stringify(response.data));
		return response.data;
	  })
	  .catch(function (error) {
	    console.log(error);
	  });
	  //const url='http://47.97.119.70:17100/club?uid=28&area=niuniuBackend&cmd=queryClub&sign=password';
	  //const response = fly.get(url);
	  //console.log("response------------22-:"+JSON.stringify(response));
	  //const response= fly.request(url, null,{method:"get"});
	  //console.log("response------------33-:"+JSON.stringify(response));
	  /**
	  fly.get(url).then(function (response) {
	    console.log("response------------11-:"+response);
	  }).catch(function (error) {
	    console.log(error);
	  });
	  */
  }
  
  async getmyclubs(){
	  
	//发送Get请求
	  const url='http://47.97.119.70:17100/club?uid=28&area=niuniuBackend&cmd=queryClub&sign=password';
	  
	  http.get(url,function(req,res){
	  	var html='';
	  	req.on('data',function(data){
	  		console.log('data--------------:'+data);
	  	});
	  	req.on('end',function(){
	  		console.info(html);
	  	});
	  });
  }
};
